Skip to content

HAR-9653 - improve import and export of html annotation#502

Merged
harbournick merged 1 commit intomainfrom
artem-HAR-9653-v1
May 18, 2025
Merged

HAR-9653 - improve import and export of html annotation#502
harbournick merged 1 commit intomainfrom
artem-HAR-9653-v1

Conversation

@artem-harbour
Copy link
Copy Markdown
Contributor

@artem-harbour artem-harbour commented May 14, 2025

Added comments in the code explaining the changes.

@artem-harbour artem-harbour self-assigned this May 14, 2025
'w:val': attrs.multipleImage,
},
},
{
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Save fontFamily and fontSize as attributes to re-import annotations correctly.

return { width, height };
}

function applyMarksToHtmlAnnotation(state, marks) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply font marks (*attributes as marks) of html annotation to inner content of annotation, but do not override if text node already has font styles. This is necessary for the final doc export, so the paragraph text look the same (as annotation).

fontSize: fontSize !== 'null' ? fontSize : null,
};

const allAttrs = { ...attrs, ...marksAsAttrs };
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For regular text fields, fontFamily and fontSize will be in attrs and marksAsAttrs. It will be overridden from the last object.

For html fields, fontFamily and fontSize will be only in attrs object.

if (type === 'html') {
/// Note: html annotation has a different structure and can include
/// several paragraphs with different styles. We could find the first paragraph
/// and take the marks from there, but we take fontFamily and fontSize from the annotation attributes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no processing for html field, since getting fontFamily and fontSize from attributes is a more correct solution in my opinion.

@artem-harbour artem-harbour marked this pull request as ready for review May 14, 2025 15:30
@artem-harbour artem-harbour requested a review from harbournick May 14, 2025 15:30
Copy link
Copy Markdown
Collaborator

@harbournick harbournick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@harbournick harbournick merged commit fc5854b into main May 18, 2025
5 of 6 checks passed
@harbournick harbournick deleted the artem-HAR-9653-v1 branch May 18, 2025 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants